package com.leetcode.LC;

public class LC747 {
    public int dominantIndex(int[] nums) {
        int max = 0, a = 0;
        for (int i = 0; i < nums.length; i++) {
            if (max < nums[i]) {
                max = nums[i];
                a = i;
            }
        }

        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != max && nums[i] * 2 > max) {
                return -1;
            }
        }
        return a;
    }

    public static void main(String[] args) {
        System.out.println(new LC747().dominantIndex(new int[]{1, 2, 3, 4}));
    }
}
